<script setup lang="ts">
import { ref } from 'vue'
import type { PrescriptionResult } from '@/types/patient'
import { onLoad } from '@dcloudio/uni-app'
import { getPrescriptionByRegId } from '@/services/prescription'

const query = defineProps<{
  registrationId: number
}>()

const prescription = ref<PrescriptionResult>()

onLoad(() => {
  let data = {
    registrationId: query.registrationId,
  }
  getPrescriptionByRegId(data).then((res) => {
    prescription.value = res.result
  })
})
</script>

<template>
  <view class="main" v-if="prescription">
    <view class="hospital">北京市神州网络医院</view>
    <view class="title">电子处方笺</view>
    <view class="qrcode">
      <uqrcode ref="qrcode" canvas-id="qrcode" size="140" :value="prescription.uuid"></uqrcode>
    </view>
    <view class="info-container">
      <view class="row">
        <text>姓名：{{ prescription.patientName }}</text>
        <text>性别：{{ prescription.patientSex }}</text>
        <text>年龄：{{ prescription.patientAge }}岁</text>
      </view>
      <view class="row">
        <text>诊室：{{ prescription.deptSub }}</text>
      </view>
      <view class="row">
        <text>临床诊断：{{ prescription.diagnosis }}</text>
      </view>
    </view>
    <view class="rp-container">
      <view class="rp-title">Rp:</view>
      <view class="rp" v-for="(one, index) of prescription.rp" :key="index">
        <view class="row">
          <text class="name">1. {{ one.name }}</text>
          <text class="num">×{{ one.num }}</text>
        </view>
        <view class="row">
          <text class="spec">{{ one.spec }}</text>
        </view>
        <view class="row">
          <text class="method">{{ one.method }}</text>
        </view>
      </view>
    </view>
    <view class="responsible-person">
      <view>
        <text class="person">处方医师：{{ prescription.doctorName }}</text>
      </view>
    </view>
  </view>
</template>

<style lang="less">
@import url('prescription.less');
</style>
